<?php
session_start(); // 必须要放在代码开头
// 校验验证码是否正确
$code = $_POST['captcha'];
// echo $code;
// die;
$captcha = $_SESSION['captcha'];
// echo $captcha;
if (strtoupper($code) == $captcha) {
    echo 'ok';
} else {
    echo 'error';
}